/**
 * SSP for APP
 * Copyright 2014 Baidu Inc. All rights reserved.
 *
 * @ignore
 * @file 表格遮罩
 * @author curarchy
 */
define(
    function (require) {
        var exports = {};

        exports.type = 'TableMask';

        function addMask() {
            var mask = this.helper.getPart('mask');

            if (!mask) {
                var body = this.helper.getPart('body');
                mask = this.helper.createPart('mask');
                body.appendChild(mask);
            }

            this.addState('locked');
        }

        function removeMask() {
            this.removeState('locked');
        }

        /**
         * 激活扩展
         *
         * @override
         */
        exports.activate = function () {
            var table = this.target;

            table.addMask = addMask;
            table.removeMask = removeMask;

            this.$super(arguments);
        };

        /**
         * 取消扩展的激活状态
         *
         * @override
         */
        exports.inactive = function () {
            var table = this.target;

            delete table.addMask;
            delete table.removeMask;

            this.$super(arguments);
        };

        var TableMask = require('eoo').create(require('esui/Extension'), exports);
        require('esui').registerExtension(TableMask);
        return TableMask;
    }
);
